package com.usaas.search.controller.admin;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.usaas.common.core.controller.BaseController;
import com.usaas.common.core.domain.AjaxResult;
import com.usaas.common.enums.BusinessType;
import com.usaas.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.usaas.common.annotation.Log;
import com.usaas.search.dto.PlatUserPointRecordsDto;
import com.usaas.search.service.IPlatUserPointRecordsService;
/**
 * 用户积分明细Controller
 *
 * @author Helios
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/admin/search/platUserPointRecords")
public class AdminPlatUserPointRecordsController extends BaseController {

    @Autowired
    private IPlatUserPointRecordsService platUserPointRecordsService;

    /**
     * 查询用户积分明细列表
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPointRecords:list')")
    @Log(title = "管理端用户积分明细list查询", businessType = BusinessType.OTHER)
    @PostMapping("/list")
    public AjaxResult list(@RequestBody PlatUserPointRecordsDto platUserPointRecordsDto) {
        List<PlatUserPointRecordsDto> list = platUserPointRecordsService.queryList(platUserPointRecordsDto);
        return AjaxResult.success(list);
    }


    /**
     * 查询用户积分明细分页列表
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPointRecords:list')")
    @Log(title = "管理端用户积分明细page查询", businessType = BusinessType.OTHER)
    @PostMapping("/page")
    public AjaxResult page(@RequestBody PlatUserPointRecordsDto platUserPointRecordsDto) {
        return platUserPointRecordsService.queryPage(platUserPointRecordsDto);
    }


    /**
     * 导出用户积分明细列表
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPointRecords:export')")
    @Log(title = "管理端导出用户积分明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,PlatUserPointRecordsDto platUserPointRecordsDto) {
        List<PlatUserPointRecordsDto> list = platUserPointRecordsService.queryList(platUserPointRecordsDto);
        ExcelUtil<PlatUserPointRecordsDto> util = new ExcelUtil<>(PlatUserPointRecordsDto.class);
        util.exportExcel(response, list, "用户积分明细数据");
    }

    /**
     * 获取用户积分明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPointRecords:query')")
    @Log(title = "管理端获取用户积分明细详情查询", businessType = BusinessType.OTHER)
    @PostMapping(value = "/getInfo")
    public AjaxResult getInfo(@RequestBody PlatUserPointRecordsDto platUserPointRecordsDto) {
        return AjaxResult.success(platUserPointRecordsService.queryById(platUserPointRecordsDto.getId()));
    }

    /**
     * 新增用户积分明细
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPointRecords:add')")
    @Log(title = "管理端新增用户积分明细", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody PlatUserPointRecordsDto platUserPointRecordsDto) {
        return toAjax(platUserPointRecordsService.add(platUserPointRecordsDto));
    }

    /**
     * 修改用户积分明细
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPointRecords:edit')")
    @Log(title = "管理端修改用户积分明细", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/edit")
    public AjaxResult edit(@RequestBody PlatUserPointRecordsDto platUserPointRecordsDto) {
        return toAjax(platUserPointRecordsService.update(platUserPointRecordsDto));
    }

    /**
     * 删除用户积分明细
     */
    @PreAuthorize("@ss.hasPermi('search:platUserPointRecords:remove')")
    @Log(title = "管理端删除用户积分明细", businessType = BusinessType.DELETE)
    @PostMapping("/del")
    public AjaxResult del(@RequestBody PlatUserPointRecordsDto platUserPointRecordsDto) {
        return toAjax(platUserPointRecordsService.removeBatch(platUserPointRecordsDto.getIds()));
    }

}
